app_name = "matrix_fo"
app_title = "Matrix Fo"
app_publisher = "yuxinyong@163.com"
app_description = "Matrix FO"
app_email = "yuxinyong@163.com"
app_license = "agpl-3.0"

doctype_js = {
    "Sales Order" : "public/js/sales_order.js"
}

doc_events = {
    #物料需求
    "Material Request": {
        "before_save": "matrix_fo.module.material.material_request.set_rate_from_item_price"
    },

    #质检单
        "Quality Inspection": {
        #"on_submit": [
            #"matrix_fo.module.quality.quality_inspection.on_submit_quality_inspection"
        #]
    },

    #物料
     "Item": {
        "before_insert":[
            "matrix_fo.api.rename_item_code"
        ],
        "after_insert":[
            "matrix_fo.api.increase_counter"
        ]
        # "on_update": "matrix_fo.rb.sync_item_in_draft_so"
    },

    # 销售订单
    "Sales Order" : {
        "on_submit": "matrix_fo.rb.sales_order_send_mq_message",
        "on_update_after_submit": "matrix_fo.rb.sales_order_send_mq_message",
        "on_cancel": "matrix_fo.module.utils.rb_utils.delete_sync_logs_for_document",
    },
    # 销售出库单
    "Delivery Note": {
        "on_update": [
            "matrix_fo.rb.delivery_note_send_mq_message"
        ],
        "on_submit": [
            "matrix_fo.rb.delivery_note_send_mq_message",
            "matrix_fo.module.stock.delivery_note.update_sales_order_qty_from_dn",
            #"matrix_fo.module.stock.delivery_note.send_delivery_note_to_sp"
        ],
        "on_update_after_submit": [
            "matrix_fo.rb.delivery_note_send_mq_message",
            #"matrix_fo.module.stock.delivery_note.send_delivery_note_to_sp",
            # "matrix_fo.module.stock.delivery_note.update_original_qty"
        ],
        "on_cancel": [
            "matrix_fo.module.stock.delivery_note.rollback_sales_order_qty_from_dn",
            "matrix_fo.module.utils.rb_utils.delete_sync_logs_for_document"
        ]
    },
    # 销售发票
    "Sales Invoice": {
        "before_print": [
            "matrix_fo.module.accountant.sales_invoice.before_print"
            ]
    },
    # 采购入库单
    "Purchase Receipt": {
        "after_insert": [
            "matrix_fo.module.stock.purchase_receipt.create_quality_inspections"
        ],
        
        "on_submit": [
                "matrix_fo.rb.purchase_receipt_send_mq_message",
            ],
        "on_update_after_submit": "matrix_fo.rb.purchase_receipt_send_mq_message",
        "on_cancel": "matrix_fo.module.utils.rb_utils.delete_sync_logs_for_document"
    },
    # 仓库
    "Warehouse": {
        # "before_insert": "matrix_fo.module.stock.warehouse.warehouse_naming"
    }
}

scheduler_events = {
    "cron": {
        "* * * * *": ["matrix_fo.rb.pull_all_mq_messages"
                      ],
    }
}

fixtures = [
    #报表同步
    {
        "dt": "Report",
        "filters":  [["module", "=", "Matrix Fo"]]
    },
    # 服务器脚本同步
    {
        "dt": "Server Script",
        "filters": [["module", "=", "Matrix Fo"]]
    },
    # 客户端脚本同步
    {
        "dt": "Client Script",
        "filters": [["module", "=", "Matrix Fo"]]
    },
    # 自定义字段同步
    {
        "dt": "Custom Field",
        "filters": [["module", "=", "Matrix Fo"]]
    }
]

after_install = "matrix_fo.install.after_install"